Members:
  • Jerry Mao
  • Eugene Goh
  • Jun Ahn

Database

A Database is a system created to organize,store, and retrieve large amounts of information and data easily.

There are three rules when creating a useful database:
Normal Form:
1. First Normal Form – Data cannot appear in duplicate rows or columns
2. Second Normal Form – Each attribute is dependent on the entire primary key
3. Third Normal Form – Data can only be related to the primary key but not the attributes

First Normal Form

There is a problem with the following database table design. Identify the error and fix the design.
(Answer: Duplicate rows of Data)

1NF_problem.jpg

Solution
1NF_Solution.jpg

1NF_Solution_2.jpg
The original table is split into two separate tables to avoid having two duplicate rows of data.

Additional Example:
normal_1_error.jpg

Solution
normal_1_sol.jpg

normal_1_sol_2.jpg

Second Normal Form

There is a problem with the following database table design. Identify the error and fix the design.
(Answer: Each attribute must be dependent on the entire primary key, instead, use a composite primary key)

Second_Normal_Form.docx_-_Microsoft_Word.jpg

Solution

Room3.docx_-_Microsoft_Word.jpg
The original table is split into two separate tables. The first table include the composite key which combines two primary keys.

Additional Example:

Second_Normal_Form6.docx_-_Microsoft_Word.jpg

Solution

Second_Normal_Form_Solution_1.docx_-_Microsoft_Word.jpg
The original table is split into two separate tables. The first table include the composite key which combines two primary keys.

Third Normal Form

There is a problem with the following database table design. Identify the error and fix the design.
(Answer: each attribute should be dependent on the primary key ONLY)

1.jpg

Solution

2.jpg


3.jpg


Additional Example:

Normal_3_example.jpg

Solution

Second_Normal_Form_Solution.docx_-_Microsoft_Word.jpg
This example's oringial table is also separated into two parts. The first table contains both primary key and foreign key. "School Name" is foreign key
because it is from the 2nd table.

Entity Relationship Diagram

An Entity Relationship Diagram(ER Diagram) is a diagram that illustrates the interrelationships between entities of a database.

Entity Relationship Diagram:


Er_diagram.docx_-_Microsoft_Word.jpg

Entity Relationship (ER) dragram rules:

1. A primary key cannot contain a null value
2. A non-primary key can contain a null value.
Note: Null value is a value that does not contain a number

An ER diagram can contain one-to-one relationships, one to many relationships, but not many to many relationships. The arrow in the above diagram illustrates the relationships.

Example:
One to One relationship: A pair of shoe can only have one company name.
One to Many Relationships: One customer can buy many video games.
One copy of video game can only be bought by one customer.
Many to Many Relationships: One student can study many courses.
One course can contain many students.